import axios from 'axios'
import { config } from 'process'
// 在此对接口进行封装
const http = axios.create({
    baseURL: import.meta.env.VITE_BASE_URL,
})

http.interceptors.request.use(
    config => {
        // console.log(config);
        // 可以在请求头里面添加token
        return config
    },
    error => {
        console.log('error', error)
        return Promise.reject(new Error(error).message)
    }
)
http.interceptors.response.use(
    response => {
        // console.log('.....', response)
        return response.data.data
    },
    error => {
        // console.log('error', error)
        return Promise.reject(new Error(error).message)
    }
)

export default http